//
//  YYJLMyMessageCell.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/3.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//  我的消息

#import "YYJLMyMessageCell.h"
@interface YYJLMyMessageCell(){
    UIImageView * headerView;//头像
    UILabel     * styleLb;//消息类型
    UILabel     * name;//姓名
    UIImageView * levelView;//等级
    UILabel     * placeLb;//职位
    UILabel     * timeLb;//时间
    UILabel     * contentLb;//评论内容
    UIImageView * showPic;//图片展示
    UILabel     * titleLb;//话题
    UIView      * bgView;//背景框
    UILabel     * titleForZanlb;//点赞的话题
}
@end
@implementation YYJLMyMessageCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
    }return self;
}
-(void)creatUI{
    //头像
    UIImage * headerImg=[UIImage imageNamed:@"touxiang2-80x80"];
    headerView=[[UIImageView alloc]initWithFrame:CGRectMake(12*PER_WIDTH, 15*PER_HEIGHT, headerImg.size.width*PER_WIDTH, headerImg.size.height*PER_WIDTH)];
    headerView.layer.cornerRadius=headerView.height/2;
    headerView.layer.masksToBounds=YES;
    headerView.image=headerImg;
    [self.contentView addSubview:headerView];
    
    //姓名
    name=[MyControl createLabelWithFrame:CGRectMake(headerView.right+10*PER_WIDTH, 20*PER_HEIGHT, 50, 15*PER_HEIGHT) Font:15 Text:@"李默尔"];
    name.textColor=UIColorFromHex(0x333333);
    [self.contentView addSubview:name];
    
    //消息类型
    styleLb=[MyControl createLabelWithFrame:CGRectMake(name.right+10*PER_WIDTH, name.top+1*PER_HEIGHT, 80*PER_WIDTH, 12) Font:12 Text:@"赞了话题"];
    styleLb.textColor=UIColorFromHex(0x999999);
    [self.contentView addSubview:styleLb];
    
    //等级
    UIImage * levelImg = [UIImage imageNamed:@"1"];
    levelView=[[UIImageView alloc]initWithFrame:CGRectMake(name.left, name.bottom+10*PER_HEIGHT, levelImg.size.width*PER_WIDTH, levelImg.size.height*PER_HEIGHT)];
    levelView.image=levelImg;
    [self.contentView addSubview:levelView];
    
    //职位
    placeLb=[MyControl createLabelWithFrame:CGRectMake(levelView.right+10*PER_WIDTH, name.bottom+10*PER_HEIGHT, 30, 12) Font:12 Text:@"店长"];
    placeLb.textColor=UIColorFromHex(0x333333);
    [self.contentView addSubview:placeLb];
    
    //回复按钮
    //1.
    UILabel * replaceLb =[MyControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-12*PER_WIDTH-28*PER_WIDTH, 20*PER_HEIGHT, 28*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:@"回复"];
    replaceLb.textColor=TINK_COLOR;
    [self.contentView addSubview:replaceLb];
    //2.
    UIImage * replaceImg=[UIImage imageNamed:@"ico_huifu"];
    
    UIImageView*replaceView=[[UIImageView alloc]initWithFrame:CGRectMake(replaceLb.left-6*PER_WIDTH-replaceImg.size.width*PER_WIDTH, replaceLb.top, replaceImg.size.width*PER_WIDTH, replaceImg.size.height*PER_HEIGHT)];
    replaceView.image=replaceImg;
    [self.contentView addSubview:replaceView];
    //3.
    UIButton * replaceBtn = [MyControl createButtonWithFrame:CGRectMake(replaceView.left, replaceView.top, replaceView.width+6*PER_WIDTH +replaceLb.width,replaceLb.height) ImageName:@"" Target:self Action:@selector(replace) Title:@""];
    replaceBtn . backgroundColor=[UIColor clearColor];
    [self.contentView addSubview:replaceBtn];
    
    //时间
    titleLb=[MyControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-12*PER_WIDTH-200*PER_WIDTH, replaceBtn.bottom+10*PER_HEIGHT, 200*PER_WIDTH, 12*PER_HEIGHT) Font:12 Text:@"一小时前"];
    titleLb.textColor=UIColorFromHex(0x999999);
    titleLb.textAlignment=NSTextAlignmentRight;
    [self.contentView addSubview:titleLb];
    
    //评论内容
    contentLb=[MyControl createLabelWithFrame:CGRectMake(headerView.left, levelView.bottom+15*PER_HEIGHT, SCREEN_WIDTH-24*PER_WIDTH, 15*PER_HEIGHT) Font:15 Text:@"的确,每颗珍珠都要一种独特的韵味"];
    contentLb.textColor=BLACK_COLOR;
    [self.contentView addSubview:contentLb];
    
    //话题
    //1.背景框
    bgView=[[UIView alloc]initWithFrame:CGRectMake(headerView.left, contentLb.bottom+10*PER_HEIGHT, contentLb.width, 110*PER_HEIGHT)];
    bgView.layer.cornerRadius=10;
    bgView.backgroundColor=UIColorFromHex(0xf2f2f2);
    [self.contentView addSubview:bgView];
    
    //2.图片
    
    showPic=[[UIImageView alloc]initWithFrame:CGRectMake(10*PER_WIDTH, 10*PER_WIDTH, 90*PER_WIDTH, 90*PER_WIDTH)];
    showPic.image=[UIImage imageNamed:@"img_huati1"];
    [bgView addSubview:showPic];
    
    //3.话题
    titleLb=[MyControl createLabelWithFrame:CGRectMake(showPic.right+10*PER_WIDTH, 30*PER_HEIGHT, 200*PER_WIDTH, 13) Font:13 Text:@"百变珍珠,凝结月神的眼泪"];
    titleLb.textColor=BLACK_COLOR;
    [bgView addSubview:titleLb];
    
    //点赞的话题
    NSString*text=[NSString stringWithFormat:@"“%@”",titleLb.text];
    titleForZanlb=[MyControl createLabelWithFrame:CGRectMake(styleLb.right+10*PER_WIDTH, styleLb.top, SCREEN_WIDTH-styleLb.right-24*PER_WIDTH, 26) Font:13 Text:text];
    [self.contentView addSubview:titleForZanlb];
    titleForZanlb.hidden=YES;
    
    
}
-(void)setIsZan:(BOOL)isZan{
    if (isZan) {
        contentLb.hidden=YES;
  
    }else{
        titleForZanlb.hidden=YES;
    }
     [self setNeedsLayout];
}
-(void)replace{
    
}
- (void)setDataDic:(NSDictionary *)dataDic
{
    if (!_dataDic) {
        _dataDic = [[NSDictionary alloc]init];
    }
    _dataDic = dataDic;
    [self setNeedsLayout];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
}
@end
